package demo.day07

// Kotlin 主构造函数 与 次构造函数
fun main() {
    // 默认会调用主构造函数
    var ktBase04_1 = KtBase04("Ki")
    ktBase04_1 = KtBase04("Ki", 'm')
    ktBase04_1 = KtBase04("Ki", 'm', 18)
    ktBase04_1 = KtBase04("Ki", 'm', 18, "2swaxgjagxajxgja")

}


class KtBase04(var name: String) {
    // 次构造函数 必须要继承自主构造
    constructor(name: String, sex: Char) : this(name) {
        println(name)
        println(sex)
    }

    constructor(name: String, sex: Char, age: Int) : this(name) {
        println(name)
        println(sex)
        println(age)
    }

    constructor(name: String, sex: Char, age: Int, infoString: String) : this(name) {
        println(name)
        println(sex)
        println(age)
        println(infoString)
    }
}